<?php

namespace AppBundle\Controller;

use AppBundle\Entity\Event;
use AppBundle\Form\Type\EventType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;

/**
 * @Route("/event")
 */
class EventController extends Controller
{
    /**
     * @Route("/show/{slug}")
     * @Template()
     */
    public function showAction($slug)
    {
        return array(
                // ...
            );    }

    /**
     * @Route("/new")
     * @Template()
     */
    public function newAction(Request $request)
    {
        $event = new Event();
        $event->setTitle('test');
        $form = $this->createForm(new EventType(), $event);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->get('doctrine_mongodb')->getManager();
            $em->persist($event);
            $em->flush();

            return $this->redirect($this->generateUrl(
                'appbundle_event_show',
                array('id' => $event->getId())
            ));
        }

        return $this->render('AppBundle:Event:new.html.twig', array(
            'form' => $form->createView(),
        ));
    }

    /**
     * @Route("/delete/{EventID}")
     * @Template()
     */
    public function deleteAction($EventID)
    {
        return array(
                // ...
            );    }

    /**
     * @Route("/archive/{EventID}")
     * @Template()
     */
    public function archiveAction($EventID)
    {
        return array(
                // ...
            );    }

    /**
     * @Route("/makeVisible/{EventID}")
     * @Template()
     */
    public function makeVisibleAction($EventID)
    {
        return array(
                // ...
            );    }

    /**
     * @Route("/makeInvisible/{EventId}")
     * @Template()
     */
    public function makeInvisibleAction($EventId)
    {
        return array(
                // ...
            );    }

}
